import json
import pygal
from pygal.style import LightColorizedStyle as LCS, LightenStyle as LS

filename = 'D:\\Python\\projects\\python_01\\files\\repositories.json'
with open(filename, encoding='utf-8') as f:
    info = json.load(f)

names, plot_dicts = [], []
for repo_dict in info:
    names.append(repo_dict['name'])
    description=repo_dict['description']
    plot_dict = {
        'value': repo_dict['stargazers_count'],
        'label': description,
        'xlink': repo_dict['html_url']
    }
    plot_dicts.append(plot_dict)

my_style = LS('#333366', base_style=LCS)
chart = pygal.Bar(style=my_style, x_label_rotation=45, show_legend=False)
chart.title = 'Most-Starred Java Projects on GitHub'
chart.x_labels = names

chart.add('', plot_dicts)
chart.render_to_file('java_repos2.svg')
print("完成！")